<template>
  <div>
    <!-- 添加 -->
    <form class="el-form demo-form-inline el-form--inline">
      <div class="el-form-item el-form-item--small">
        <!---->
        <div class="el-form-item__content">
          <button
            type="button"
            class="el-button el-button--primary el-button--small"
          >
            <!----><!----><span>添加</span></button
          ><!---->
        </div>
      </div>
    </form>
    <!-- 内容 -->
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="id" label="id" width="180"> </el-table-column>
      <el-table-column prop="name" label="分类名称" width="180">
      </el-table-column>
      <el-table-column prop="type" label="分类级别">
        <!-- <template v-slot="scope">
          {{ scope.row.type ? "顶级分类" : "垃圾分类" }}
        </template> -->
      </el-table-column>
      <el-table-column prop="img_url" label="图片"> </el-table-column>
      <el-table-column prop="is_show" label="是否显示">
        <template v-slot="scope">
          {{ scope.row.is_show ? "是" : "否" }}
        </template>
      </el-table-column>
      <el-table-column prop="sort_order" label="排序"> </el-table-column>
      <el-table-column label="操作">
        <template>
          <el-button class="bianji" size="mini">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { GetCategoryApi } from "@/request/httpApi.js";
export default {
  data() {
    return {
      tableData: [],
      currentPage: 1, //页码
      pageSize: 10, //一页的条数
      total: 0, //总条数
      searchs: "", //
    };
  },
  methods: {
    categoryData() {
      GetCategoryApi({
        // 当前页
        page: this.currentPage,
        //   商品名称
        name: "",
        //   一页显示多少条
        size: this.pageSize,
      }).then((res) => {
        if (res.errno === 0) {
          this.tableData = res.data.data;
          this.total = res.data.count;
        }
      });
    },
    handleSizeChange(size) {
      this.pageSize = size;
      this.categoryData();
    },
    handleCurrentChange(page) {
      this.totalPages = page;
      this.categoryData();
    },
  },
  created() {
    this.categoryData();
  },
};
</script>
 
<style lang = "less" scoped>
.bianji {
  color: #fff;
  background-color: #409eff;
  border-color: #409eff;
}
</style>

